package com.yazi.mxz.common.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.myframework.smhj.hibernate.dao.BasicService;
import com.myframework.smhj.hibernate.dao.Dao;
import com.yazi.mxz.common.db.dao.SettingDao;
import com.yazi.mxz.common.entity.ValueFactory;
import com.yazi.mxz.common.entity.beans.Setting;
import com.yazi.mxz.common.service.SettingService;

@Service("settingService")
public class SettingServiceImpl extends BasicService<Setting> implements SettingService {
	private static Logger log = LoggerFactory.getLogger(SettingServiceImpl.class);

	@Resource
	SettingDao settingDao;
	
	@Override
	protected Dao<Setting> getDao() {
		return settingDao;
	}
	
	@Override
	public Setting edit(Setting setting) {
		log.debug("modify：settingId={}", setting.getSettingId());
		Setting oldSetting = settingDao.get(setting.getSettingId());
		ValueFactory.combine(setting, oldSetting);
		return settingDao.merge(oldSetting);
	}

	@Override
	public List<Setting> listAll() {
		log.debug("listAll：");
		return settingDao.listAll();
	}

}
